package com.fun_ordering.entity;

/**
 * @author 陈星
 * @date 2024/3/24 14:37
 */

import com.fun_ordering.pojo.FoEmployee;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;

/**
 * entity额外增加的一个工具类
 */
public class LoginUser implements UserDetails {
    //将我们自己的User对象定义在LoginUser实现类中
    private FoEmployee foEmployee;

    public LoginUser() {
    }

    public LoginUser(FoEmployee foEmployee) {
        this.foEmployee = foEmployee;
    }

    public FoEmployee getFoEmployee() {
        return foEmployee;
    }

    public void setFoEmployee(FoEmployee foEmployee) {
        this.foEmployee = foEmployee;
    }

    /**
     * 提供get和set方法
     * @return
     */


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        //返回用户密码
        return foEmployee.getEmpPassword();
    }

    @Override
    public String getUsername() {
        //返回用户名
        return foEmployee.getEmpAccount();
    }

    //是否未过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
    //是否未锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }
    //凭证是否未过期
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }
    //是否可用
    @Override
    public boolean isEnabled() {
        return true;
    }
}
